package com.weiyi.servlet01;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
 * 
 * @description 第一个servlet程序
 * @author 惟一
 * @date 2020年6月26日下午6:01:37
 */
@WebServlet(name = "hello",urlPatterns = "/Hello.view",loadOnStartup = 1)
public class HelloDemo extends HttpServlet{
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		resp.setContentType("text/html;charset=UTF-8");
		PrintWriter out = resp.getWriter();
		String name = req.getParameter("name");
		
		out.println("<html>");
		out.println("<head>");
		out.println("<title>Hello Servlet</title>");
		out.println("</head>");
		out.println("<body>");
		out.println("<h1>Hello! "+name+" !</h1>");
		out.println("</body>");
		out.println("</html>");
		
		out.close();
	}
}
